package com.hsy.baoinbao.modules.order.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hsy.baoinbao.R;

/**
 * Created by hsy on 2016/3/24.
 */
public class GarbageItemView extends LinearLayout {
    View root;
    TextView name;
    TextView price;
    TextView unit;

    public GarbageItemView(Context context) {
        super(context);
        init(context);
    }

    public GarbageItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public GarbageItemView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context) {
        root = inflate(context, R.layout.item_garbage, null);
        name = (TextView) root.findViewById(R.id.name);
        price = (TextView) root.findViewById(R.id.price);
        unit = (TextView) root.findViewById(R.id.unit);

        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        addView(root, params);
    }

    public void setData(String name, String price, String unit) {
        this.name.setText(name);
        this.price.setText(price);
        this.unit.setText(unit);
    }
}
